package org.makcro.sms.services.chat.web.client;

import org.makcro.sms.services.chat.web.client.mvc.AgentsMessagesController;
import org.makcro.sms.services.chat.web.client.mvc.AllMessagesController;
import org.makcro.sms.services.chat.web.client.mvc.AnswerController;
import org.makcro.sms.services.chat.web.client.mvc.LoginController;
import org.makcro.sms.services.chat.web.client.mvc.MainController;
import org.makcro.sms.services.chat.web.client.mvc.NewMessagesController;
import org.makcro.sms.services.chat.web.client.services.login.LoginService;
import org.makcro.sms.services.chat.web.client.services.login.LoginServiceAsync;
import org.makcro.sms.services.chat.web.client.services.message.MessageService;
import org.makcro.sms.services.chat.web.client.services.message.MessageServiceAsync;

import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.extjs.gxt.ui.client.util.Theme;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;

public class SmsChat implements EntryPoint {

	public void onModuleLoad() {

		GXT.setDefaultTheme(Theme.BLUE, true );
		initServices();

		Dispatcher dispatcher = Dispatcher.get();
		dispatcher.addController(new LoginController());
		dispatcher.addController(new MainController());
		dispatcher.addController(new NewMessagesController());
		dispatcher.addController(new AllMessagesController());
		dispatcher.addController(new AgentsMessagesController());
		dispatcher.addController(new AnswerController());
		
		dispatcher.dispatch(AppEvents.ShowLoginDialog);
	}

	private void initServices() {
		LoginServiceAsync loginService = GWT.create(LoginService.class);
		MessageServiceAsync messageService = GWT.create(MessageService.class);
		
		Registry.register(Constants.Services.LoginService, loginService);
		Registry.register(Constants.Services.MessageService, messageService);
	}

}
